package teach.aistar.util;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class DateUtil {
    //字符串转时间
    public  static Date stringToDate(String date) throws ParseException {

        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");

        Date newTime = format.parse(date);

        return newTime;
    }

    //时间转字符串
    public  static String dateToString(Date date) throws ParseException {

        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

        String newTime = format.format(date);

        return newTime;
    }
}
